package cn.scw.project.facility.domain.netework.bean;

import cn.scw.common.constant.StateConst;
import cn.scw.common.utils.DateUtils;
import cn.scw.common.utils.sql.JpaUtil;
import cn.scw.framework.web.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Date;

/**
 * 打印订单对象 fac_print_order
 *
 * @author api
 * @date 2020-05-20
 */
@Data
@ApiModel("打印订单")
public class FacPrintOrderListReq extends BaseEntity {

    @ApiModelProperty("设备编号")
    private String facilityCode;

    @ApiModelProperty("用户名称")
    private String userName;

    @ApiModelProperty("订单编号")
    private String number;

    @ApiModelProperty("打印类型（照片，文档）")
    private String type;

    @ApiModelProperty("打印规格，尺寸")
    private String typeCode;

    @ApiModelProperty("最小打印数量")
    private Integer minCount;

    @ApiModelProperty("最大打印数量")
    private Integer maxCount;

    @ApiModelProperty("打印标题（结婚照，签证照，证件照等）")
    private String title;

    // @ApiModelProperty("查询类型：DAY-天；WEEK-周；MONTH-月；QUARTER-季；YEAR-年；默认-天")
    @ApiModelProperty(value = "查询类型：DAY-天；WEEK-周；MONTH-月；null-全部",hidden = true)
    private String dateType;

    @ApiModelProperty(value = "开始时间")
    private Date startDate;

    @ApiModelProperty(value = "结束时间")
    private Date endDate;

    @ApiModelProperty(value = "经销商id", hidden = true)
    private Long dealerId;

    public void initData(Long dealerId) {
        this.dealerId = dealerId;
        initData();
    }

    public void initData() {
        this.title = JpaUtil.getNullOrLikeStr(this.title);
        this.userName = JpaUtil.getNullOrLikeStr(this.userName);

        if (this.dateType == null) {
            return;
        }
        Date nowDate = new Date();
        switch (this.dateType) {
            case StateConst.DATE_DAY:
                this.startDate = DateUtils.getDay(nowDate, DateUtils.start);
                this.endDate = DateUtils.getDay(nowDate, DateUtils.end);
                break;
            case StateConst.DATE_WEEK:
                this.startDate = DateUtils.getWeekDay(nowDate, DateUtils.start);
                this.endDate = DateUtils.getWeekDay(nowDate, DateUtils.end);
                break;
            case StateConst.DATE_MONTH:
                this.startDate = DateUtils.getMonthDay(nowDate, DateUtils.start);
                this.endDate = DateUtils.getMonthDay(nowDate, DateUtils.end);
                break;
        }
    }
}
